﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace MyHomeworkWebAPi.Models.ef;

public partial class Product
{
    public Product()
    {
        Comments = new HashSet<Comment>();
        Orders = new HashSet<Order>();
        Interactions = new HashSet<Interaction>();
    }

    /// <summary>
    /// 商品ID
    /// </summary>
    [Key]
    public Guid ProductId { get; set; }

    /// <summary>
    /// 发布者ID
    /// </summary>
    [Required]
    public Guid UserId { get; set; }

    /// <summary>
    /// 商品标题
    /// </summary>
    [Required]
    [StringLength(100)]
    public string Title { get; set; } = null!;

    /// <summary>
    /// 价格
    /// </summary>
    [Required]
    [Column(TypeName = "decimal(18,2)")]
    public decimal Price { get; set; }

    /// <summary>
    /// 分类ID
    /// </summary>
    [Required]
    public Guid CategoryId { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    [StringLength(20)]
    public string Status { get; set; } = null!;

    /// <summary>
    /// 描述
    /// </summary>
    [Required]
    [StringLength(1000)]
    public string Description { get; set; }

    /// <summary>
    /// 商品图片
    /// </summary>
    public byte[]? Image { get; set; }

    [ForeignKey("UserId")]
    public virtual User User { get; set; } = null!;

    [ForeignKey("CategoryId")]
    public virtual ProductCategory Category { get; set; } = null!;

    public virtual ICollection<Comment> Comments { get; set; } = new List<Comment>();

    public virtual ICollection<Order> Orders { get; set; } = new List<Order>();

    public virtual ICollection<Interaction> Interactions { get; set; } = new List<Interaction>();
}
